"""
16_streaming.py - Streaming Patterns
Run: python src/16_streaming.py
See the PDF book for detailed explanation and concepts.
"""
from typing import TypedDict, Annotated
from operator import add
from langgraph.graph import StateGraph, START, END

class DemoState(TypedDict):
    input: str
    output: str
    messages: Annotated[list, add]

def process_step(state: DemoState) -> dict:
    return {
        "output": f"[Streaming Patterns] Processed: {state['input']}",
        "messages": ["Step completed successfully"]
    }

graph = StateGraph(DemoState)
graph.add_node("process", process_step)
graph.add_edge(START, "process")
graph.add_edge("process", END)
app = graph.compile()

if __name__ == "__main__":
    print("=" * 60)
    print("16: Streaming Patterns")
    print("=" * 60)
    result = app.invoke({"input": "test data"})
    print(f"\n  Output: {result['output']}")
    print(f"\n  See LangGraph_Mastery_Complete_Book.pdf for full implementation!")
    print(f"\n{'=' * 60}")
    print("Complete!")
